<template>
	<view class="content">
		<view class="list" v-if="list.length">
			<cmd-cell-item style="border-bottom: 1rpx solid #dedede;" v-for="(item,index) in list" :key="index" :title="item.nickname"
			 :brief="item.logintime" @click="onClick" addon="查推荐" />
		</view>
		<view class="nodata" v-else>
			<view class="fonticon icon">
				&#xe602;
			</view>
			<view class="txt">
				暂无推荐记录
			</view>
		</view>
	</view>
</template>

<script>
	import cmdCellItem from '@/components/cmd-cell-item/cmd-cell-item.vue'

	// 接口相关
	import _function from '@/common/_function.js'
	import api from '@/common/api.js'


	export default {
		components: {
			cmdCellItem
		},
		data() {
			return {
				list: [],
				pages: 1
			};
		},
		methods: {
			onClick() {
				uni.navigateTo({
					url: '../subordinate/subordinate'
				})
			},
			async getrecommend(){
				const res = await _function.request(api.getrecommend, {
					pages: this.pages
				}, 'POST')
				if (res.data.code == 200) {
					if (res.data.data != 'null') {
						if(this.pages==1){
							this.list = res.data.data
						}else{
							this.list = this.list.concat(res.data.data)
						}
					} else {
						uni.showToast({
							title: '您暂时还没有推荐人',
							duration: 2000,
							icon: 'none'
						})
					}
				} else {
					uni.showToast({
						title: '获取推荐失败',
						duration: 2000,
						icon: 'none'
					})
				}
			}
		},
		onLoad() {
			this.getrecommend()
		},

		onReachBottom(e) {
			this.pages++
			this.getrecommend()
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
	}

	.content {
		height: 100%;


		.list {
			box-sizing: border-box;
			padding: 20rpx 10rpx;
		}

		.nodata {
			height: 100%;
			display: flex;
			justify-content: center;
			align-items: center;

			.icon {
				font-size: 80rpx;
			}

			.txt {
				font-size: 40rpx;
			}
		}
	}
</style>
